/* eslint-disable indent */
import { connect } from 'dva';
import React, { Component } from 'react';
import { Table, Pagination, Popconfirm, Button } from 'antd';
import MainLayout from '../components/MainLayout/MainLayout';
import ${className}CreateForm from '../components/${moduleName}/${classObjectName}/${className}CreateForm';
import ${className}List from '../components/${moduleName}/${classObjectName}/${className}List';

const ButtonGroup = Button.Group;
const ${className}Page  = ({dispatch,location,selectedRowKeys}) =>{
    const handleDelete = () =>{
        dispatch({type: '${classObjectName}/delete',payload:{selectedRowKeys}});
    };

    const body =(
    <MainLayout location={location}>
        <div>
            <ButtonGroup>
                <${className}CreateForm>
                    <Button type="primary" icon="plus-circle-o">新增</Button>
                </${className}CreateForm>
                <Popconfirm title="删除的数据不能恢复，确定要全部删除吗?" onConfirm={handleDelete} okText="确定" cancelText="取消">
                    <Button type="primary" disabled={null!=selectedRowKeys && selectedRowKeys.length > 0 ? false : true}  icon="delete">
                        {null!=selectedRowKeys && selectedRowKeys.length > 1 ? '批量删除' : '删除'}
                    </Button>
                </Popconfirm>
            </ButtonGroup>
            <${className}List></${className}List>
        </div>
    </MainLayout>
    );

    return body ;
};

function mapStateToProps(state) {
    const {selectedRowKeys} = state.${classObjectName};
    return { selectedRowKeys };
}

export default connect(mapStateToProps)(${className}Page);

